<template>
    <div>
        <div class="wrapper" v-if="detail">

            <div class="container" v-if="detail">
                <div class="title">
                    <span>{{detail.title}}</span>

                </div>
                <div class="info">
                    <span>{{detail.user}}</span>
                    <span>{{formatDate(detail.date)}}</span>
                </div>
                <div v-html="detail.content"></div>

            </div>
        </div>
        <div v-else>
            <el-skeleton :rows="27" animated />
        </div>
    </div>
</template>

<script lang="ts" setup>
import { ref } from "vue";
import { useRoute } from "vue-router";
import { announcementDetailApi } from "../../../../api/a";
import { responseCallback } from "../../../../utils";
import { formatDate } from "../../../../utils/date";

const route = useRoute();
const { params: { id } } = route;

const detail = ref(null);

responseCallback({
    promise: announcementDetailApi(undefined, { id }),
    cb(data) {
        detail.value = data;
    }
})
</script>

<style lang="less" scoped>
.container {
    width: 1000px;
    margin: 0 auto;
    padding: 0 50px;
    min-height: 80vh;
}

.title {
    text-align: center;

    &>span {
        text-align: center;
        padding-bottom: 1rem;
        color: #333;
        text-align: center;
        margin-bottom: 5px;
        font-size: 28px;
        display: inline-block;
        border-bottom: 1px solid #ccc;
        font-weight: 400;
    }
}

.wrapper {
    position: relative;
}

img {
    display: inline-block;
}

.back-btn {
    position: absolute;
    left: 0;
    transform: translateY(-100%);
    width: 150px;
    font-size: 30px;
    cursor: pointer;
    color: var(--el-color-primary);
    transition: all .5s;

}

.info {
    text-align: center;
    font-size: 14px;
    margin-bottom: 1rem;

    span {
        display: inline-block;
        margin-right: 1rem;
    }
}

.a {
    margin-top: 1rem;
    display: flex;
}
</style>